$(function() {
	
	var eventIdForModify = document.getElementById("eventIdForModify").value;
	if(eventIdForModify==""){
		document.getElementById("addDiv").style.display='none';
	}else{
		document.getElementById("addDiv").style.display='';
	}
	var viewFlag=$('#viewFlag').val();
	if(viewFlag=='1'){
		$('#day').attr('disabled',true);
		$('#startTime').attr("disabled",true);
		$('#endTime').attr("disabled",true);
		$('#title').attr("disabled",true);
		$('#place').attr("disabled",true);
		$('#memo').attr("disabled",true);
		$('#viewFlag').val("");
	}
	//日程追加
	$("#addEvent").click(function() {
		$("#day").val("");
		$("#startTime").val("");
		$("#endTime").val("");
		$("#place").val("");
		$("#title").val("");
		$("#memo").val("");
		$('#day').attr("disabled",false);
		$('#startTime').attr("disabled",false);
		$('#endTime').attr("disabled",false);
		$('#title').attr("disabled",false);
		$('#place').attr("disabled",false);
		$('#memo').attr("disabled",false);
	});
	
	//日程登陆
	$("#comfirm").click(function() {
		var successFlag=true; 
		if($("#day").val() == null || $("#day").val() == ""){
			alert("请输入日期");
			successFlag=false; 
			return;
		}
		if($("#startTime").val() == null || $("#startTime").val() == ""){
			alert("请输入开始时间");
			successFlag=false; 
			return;
		}
		if($("#endTime").val() == null || $("#endTime").val() == ""){
			alert("请输入结束时间");
			successFlag=false; 
			return;
		}
		if($("#title").val() == null || $("#title").val() == ""){
			alert("请输入活动名称");
			successFlag=false; 
			return;
		}
		if($("#place").val() == null || $("#place").val() == ""){
			alert("请输入活动地址");
			successFlag=false; 
			return;
		}
		if(successFlag){
			var eventIdForModify=$("#eventIdForModify").val();
			var scheduleIdForModify=$("#scheduleIdForModify").val();
			document.forms[0].action ="../webtask/saveEventManagerInfo.action?eventIdForModify="+eventIdForModify+"&scheduleIdForModify="+scheduleIdForModify;
			document.forms[0].submit();
		}
		
	});
	
	//日程修改
	$(".eventInfoEdit").click(function() {
		document.getElementById("addDiv").style.display='';
		var eventId=$(this).next().next().next().val();
		var scheduleId=$(this).next().next().next().next().val();
		$("#eventIdForModify").val(eventId);
		$("#scheduleIdForModify").val(scheduleId);
		document.forms[0].action ="../webtask/modifyEventManagerInfo.action?eventId="+eventId+"&scheduleId="+scheduleId;
		document.forms[0].submit();
	});
	
	//日程查看
	$(".eventInfoView").click(function() {
		document.getElementById("addDiv").style.display='';
		var eventId=$(this).next().next().val();
		var scheduleId=$(this).next().next().next().val();
		document.forms[0].action ="../webtask/viewEventManagerInfo.action?eventId="+eventId+"&scheduleId="+scheduleId;
		document.forms[0].submit();
	});
	
	//日程删除
	$(".eventInfoDelete").click(function() {
		var eventId=$(this).next().val();
		var scheduleId=$(this).next().next().val();
		document.forms[0].action ="../webtask/delectEventManagerInfo.action?eventId="+eventId+"&scheduleId="+scheduleId;
		document.forms[0].submit();
	});
	
	//页面返回
	$("#return").click(function() {
		var orderId=$("#orderId").val();
		document.forms[0].action ="../webtask/setTaskInfoInit.action?orderId="+orderId;
		document.forms[0].submit();
	});
});

